package pyf.demo06;

/**
 * 线程休眠
 */
public class ThreadSleepDemo implements Runnable{
    private Integer num=10;

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            if(timeOver(num)){
                try {
                    Thread.sleep(1000);

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("倒计时:"+num--);
            }
        }


    }
private boolean timeOver(int num){
        if(0>=num){
            System.out.println("倒计时结束");
            return false;
        }
        return true;
}
    public static void main(String[] args) {
       new Thread(new ThreadSleepDemo()).start();
    }
}
